package com.fhyc.vo;

import lombok.Data;

/**
 * 返回值模型
 *
 */
@Data
public class ResponseResultVO<T> {

    String message;

    int code;

    T data;

    public ResponseResultVO(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseResultVO() {
        this(200, "成功", null);
    }

    public ResponseResultVO(T data) {
        this(200, "成功", data);
    }

    public ResponseResultVO(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResponseResultVO<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    public ResponseResultVO<T> success() {
        this.code = 200;
        this.message = "成功";
        return this;
    }

    public ResponseResultVO<T> fail() {
        this.code = 401;
        this.message = "失败";
        return this;
    }

    public ResponseResultVO<T> setData(T data) {
        this.data = data;
        return this;
    }
}
